import time
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
# o = driver.find_element(By.XPATH,'//input')
# a = driver.find_element(By.XPATH,'//input[@id="kw"]/..')
# b = driver.find_element(By.XPATH,'//*[@id="form"]/span[1]/input[1]')
# c = driver.find_element(By.XPATH,'//input[@class = "s_ipt" and @name="wd"]')
# b = driver.find_element(By.XPATH,'//a[contains(text(),"地图")]')
# e = driver.find_element(By.XPATH,'//a[contains(@href,"http://map.")]')
# print(b.get_attribute('outerHTML'))
#------------------------------------------------------------------------------
#标签和属性
a = driver.find_element(By.XPATH,'//input')
b = driver.find_element(By.XPATH,'//*[@id="kw"]')
#层级
c = driver.find_element(By.XPATH,'//div//input[@id="kw"]')
d = driver.find_element(By.XPATH,'//input[@id="kw"]/..')
#标签索引
e = driver.find_element(By.XPATH,'//div[@id="form"]/span[1]/input[1]')
#逻辑运算
f = driver.find_element(By.XPATH,'//input[@id="kw" and @class ="s_ipt"]')
#模糊匹配 关键字contains
g = driver.find_element(By.XPATH,'//a[contains(text(),"新闻")]')
h = driver.find_element(By.XPATH,'//*[contains(@id,"k")]')